#ifndef SITUATION_H
#define SITUATION_H

#include <QWidget>
#include <QTcpSocket>
#include <QtCharts/QChartView>
#include <QtCharts/QPieSeries>
#include <QtCharts/QPieSlice>

namespace Ui {
class Situation;
}

class Mainpage;  // 前向声明

class Situation : public QWidget
{
    Q_OBJECT

public:
    explicit Situation(const QString &employeeId, QWidget *parent = nullptr);
    ~Situation();

protected:
    // 用于拖动窗口的事件处理函数
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

    void paintEvent(QPaintEvent *event) override;

private slots:
    void on_returnButton_clicked();
    void onDataReceived();  // 用于接收服务器数据
    void drawPieChart(int totalCheckIns, int successfulCheckIns, int resignCounts, int leaveCounts, int missingCheckIns); // 绘制饼状图

private:
    Ui::Situation *ui;
    QString employeeId;  // 存储工号
    QTcpSocket *tcpSocket;  // 用于通信

    // 用于记录拖动时鼠标位置的成员变量
    QPoint m_dragPosition;

    // 添加用于判断是否点击标题栏的成员变量
    bool m_isTitleBarClicked = false;
};

#endif // SITUATION_H
